package com.ktjy.service.impl;

import com.ktjy.entity.StorageRecord;
import com.ktjy.entity.Supplier;
import com.ktjy.mapper.StorageRecordMapper;
import com.ktjy.service.StorageRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StorageRecordServiceImpl implements StorageRecordService {
    @Autowired
    StorageRecordMapper storageRecordMapper;

    @Override
    public int saveBatchStorageRecord(StorageRecord storageRecord) {
//        if (true) {
//            //插入到第二天数据时,模拟数据库异常,查看事务是否生效
//            throw new RuntimeException("数据库异常");
//        }
        return storageRecordMapper.insertStorageRecord(storageRecord);
    }

    @Override
    public int delStorageRecordById(Long id) {
     return storageRecordMapper.deleteStorageRecord(id);
    }

    @Override
    public int updateStorageRecord(StorageRecord storageRecord) {
        return storageRecordMapper.updateStorageRecord(storageRecord);
    }
}
